/*
 * @Author: huangtianyang 916072572@qq.com
 * @Date: 2023-04-21 15:23:09
 * @LastEditors: huangtianyang
 * @LastEditTime: 2023-04-26 15:46:38
 * @FilePath: \cxl-h5\src\apis\invoice\index.ts
 */
import { request as axios } from '@/axios/index'

/**
 * 查询开票记录列表
 * @param current
 * @param size
 * @returns
 */
export const invoiceRecordList = (current: number, size: number) => {
    return axios({
        method: 'get',
        url: '/api/mall/invoice/queryInvoiceRecords',
        params: { current, size }
    })
}

/**
 * 未开票的订单
 * @param current
 * @param size
 * @returns
 */
export const noInvoiceOrderList = (current: number, size: number) => {
    return axios({
        method: 'get',
        url: '/api/mall/invoice/pageNoInvoiceOrderList',
        params: { current, size }
    })
}

export interface applyForInterface {
    address?: string //注册地址
    amount?: string //发票金额
    bankAccount?: string //银行账户
    email?: string //邮箱
    invoiceCompany?: string //抬头名称
    openingBank?: string //开户行
    orderIdList?: string[] //订单id列表
    phone?: string //手机号
    registerPhone?: string //注册电话
    taxNumber?: string //税号
    titleType?: number //抬头类型（1.企业；2.个人）
}

/**
 * 申请开票
 * @param data
 * @returns
 */
export const applyForInvoice = (data: applyForInterface) => {
    return axios({
        method: 'post',
        url: '/api/mall/invoice/add',
        data
    })
}

/**
 * 通过 id 获取发票详情
 * @param id
 * @returns
 */
export const invoiceDetailed = (id: string) => {
    return axios({
        method: 'get',
        url: '/api/mall/invoice/findById',
        params: { id }
    })
}
